# 2.8 onStart and onStop callback configuration

In the JFinalConfig subclass, you can add onStart() and onStop() methods. JFinal will callback these two methods respectively after the system has finished starting and before the system shuts down:

// Called after the system has started
public void onStart() {
}
 
// Called before the system shuts down
public void onStop() {
}
1
2
3
4
5
6
7

These two methods provide a convenient way for developers to perform additional operations after the project starts and before it shuts down. For example, after the system starts, you can create a scheduling thread or write back to the cache before the system shuts down.

Note: In versions of jfinal prior to 3.6, these two methods were named afterJFinalStart() and beforeJFinalStop(). To reduce the cognitive load, code input, and the likelihood of input errors, jfinal version 3.6 changed to the current shorter method names. The old method names are still retained and can still be used, making it easy for older projects to upgrade to the latest version of jfinal.

Last Updated: 9/17/2023, 5:34:57 AM